package com.mhjy.input.controller;

import com.mhjy.input.repository.model.*;
import com.mhjy.input.service.IInputService;
import com.mhjy.input.service.INhMbMemberService;
import com.mhjy.input.service.INhSoDetailService;
import com.mhjy.input.service.INhSoMasterService;
import com.mhjy.input.repository.entity.NhMbMemberEntity;
import com.mhjy.input.repository.entity.NhSoDetailEntity;
import com.mhjy.input.repository.entity.NhSoMasterEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@Api("dc库接口")
@RestController
@RequestMapping("/api/base")
public class BaseController {

    @Autowired
    private INhMbMemberService nhMbMemberService;
    @Autowired
    private INhSoDetailService nhSoDetailService;
    @Autowired
    private INhSoMasterService nhSoMasterService;
    @Autowired
    private IInputService inputService;

    @ApiOperation(value = "add", notes = "添加老人")
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ResponseBody
    public BaseResultModel add(@RequestBody NhMbMemberEntity entity) {
        return nhMbMemberService.add(entity);
    }


    @ApiOperation(value = "getSimpleMember", notes = "查询老人")
    @RequestMapping(value = "/getSimpleMember", method = RequestMethod.GET)
    @ResponseBody
    public BaseResultModel getSimpleMember() {
        return inputService.GetNHMBMember();
    }

    @ApiOperation(value = "inputMember", notes = "批量添加老人")
    @RequestMapping(value = "/inputMember", method = RequestMethod.POST)
    @ResponseBody
    public BaseResultModel inputMember(@RequestBody List<MbMemberInputModel> inputModelList) {
        return inputService.InputMember(inputModelList);
    }


//    @ApiOperation(value = "inputSoMaster", notes = "添加费用主表")
//    @RequestMapping(value = "/inputSoMaster", method = RequestMethod.POST)
//    @ResponseBody
//    public BaseResultModel inputSoMaster(@RequestBody SoMasterInputModel input) {
//        NhSoMasterEntity entity = new NhSoMasterEntity();
//        entity.setEntryClass("N");
//        entity.setEntryTime(new Date());
//        entity.setEntryBy("10000000610");
//        entity.setLastUpdatedBy("admin");
//        entity.setLastUpdatedTime(new Date());
//        entity.setComments(input.getComments());
//
//        entity.setDiscountOffAmt(input.getDiscountOffAmt());
//        entity.setLogisticType("03");
//        entity.setMbName(input.getMbName());
//        entity.setMbNo(input.getMbNo());
//        entity.setOrgId(input.getOrgId());
//        entity.setPayBy(input.getPayBy());
//        entity.setReceiptNo(input.getReceiptNo());
//        entity.setRefBatchAppNo(input.getRefBatchAppNo());
//        entity.setRefSoNo(input.getRefSoNo());
//        entity.setSoAmt(input.getSoAmt());
//        entity.setSoDate(input.getSoDate());
//        entity.setSoPeriod(input.getSoPeriod());
//        entity.setSoStatus("04");
//        entity.setSoRetailAmt(input.getSoRetailAmt());
//        entity.setSoType(input.getSoType());
//        entity.setRefSoDepositNo(input.getRefSoDepositNo());
//        entity.setRemarks(input.getRemarks());
//        entity.setSoNo(input.getSoNo());
//        return nhSoMasterService.add(entity);
//    }

//    @ApiOperation(value = "inputSoDetail", notes = "添加费用明显表")
//    @RequestMapping(value = "/inputSoDetail", method = RequestMethod.POST)
//    @ResponseBody
//    public BaseResultModel inputSoDetail(@RequestBody SoDetailInputModel input) {
//
//        NhSoDetailEntity entity = new NhSoDetailEntity();
//        entity.setComments(input.getComments());
//        entity.setDiscountOffAmt(input.getDiscountOffAmt());
//        entity.setLastUpdatedBy("admin");
//        entity.setLastUpdatedTime(new Date());
//        entity.setLineNo(input.getLineNo());
//        entity.setSoNo(input.getSoNo());
//        entity.setSoDesc(input.getSoDesc());
//        entity.setSoQty(input.getSoQty());
//        entity.setOrgId(input.getOrgId());
//        entity.setProductCode(input.getProductCode());
//        entity.setProductPrice(input.getProductPrice());
//        entity.setProductDesc(input.getProductDesc());
//        entity.setProductPeriod(input.getProductPeriod());
//        entity.setProductEndDate(input.getProductEndDate());
//        entity.setProductStartDate(input.getProductStartDate());
//        entity.setProductType(input.getProductType());
//        entity.setSoPrice(input.getSoPrice());
//        entity.setRemarks(input.getRemarks());
//        return nhSoDetailService.add(entity);
//    }


    @ApiOperation(value = "inputSo", notes = "添加费用数据")
    @RequestMapping(value = "/inputSo", method = RequestMethod.POST)
    @ResponseBody
    public BaseResultModel inputSo(@RequestBody InsertSoModel insertSoModel) {
        return inputService.InsertSo(insertSoModel);
    }
}
